﻿
<path d="@GetPath()"
      r="@StrokeWidth"
      fill="rgba(@Color.Transparent.R,@Color.Transparent.G,@Color.Transparent.B,@Color.Transparent.A)"
      stroke="rgba(@StrokeColor.R,@StrokeColor.G,@StrokeColor.B,@StrokeColor.A)"
      stroke-dasharray="@StrokeDashArray" stroke-linejoin="@Join.ToString().ToLower()"
      stroke-linecap="@Cap.ToString().ToLower()"
      stroke-width="@StrokeWidth"
      @onclick="OnClick"
      @ondblclick="OnDoubleClick"
      @onmousemove="OnMouseMove"
      @onmousewheel="OnMouseWheel"
      @ondrag="OnDrag"
      @onmousedown="OnMousePressed"
      @onmouseup="OnMouseReleased"
      style="opacity:@Opacity">
</path>

@code
{
    [Parameter]
    public int X1 { get; set; }
    [Parameter]
    public int Y1 { get; set; }
    [Parameter]
    public int X2 { get; set; }
    [Parameter]
    public int Y2 { get; set; }
    [Parameter]
    public int X3 { get; set; }
    [Parameter]
    public int Y3 { get; set; }
    [Parameter]
    public int X4 { get; set; }
    [Parameter]
    public int Y4 { get; set; }
    [Parameter]
    public double Opacity { get; set; } = 1;
    [Parameter]
    public Color StrokeColor { get; set; } = Color.Black;
    [Parameter]
    public double StrokeWidth { get; set; } = 2;
    [Parameter]
    public StrokeLineCap Cap { get; set; }
    [Parameter]
    public StrokeLineJoin Join { get; set; }
    [Parameter]
    public int StrokeDashArray { get; set; }

    [Parameter]
    public EventCallback<MouseEventArgs> OnClick { get; set; }
    [Parameter]
    public EventCallback<MouseEventArgs> OnDoubleClick { get; set; }
    [Parameter]
    public EventCallback<MouseEventArgs> OnMouseMove { get; set; }
    [Parameter]
    public EventCallback<WheelEventArgs> OnMouseWheel { get; set; }
    [Parameter]
    public EventCallback<DragEventArgs> OnDrag { get; set; }
    [Parameter]
    public EventCallback<MouseEventArgs> OnMousePressed { get; set; }
    [Parameter]
    public EventCallback<MouseEventArgs> OnMouseReleased { get; set; }
    
    private string GetPath()
    {
        return $"M{X1},{Y1} C{X2},{Y2} {X3},{Y3} {X4},{Y4}";
    }
}
